home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / sprintf.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  740b  |  45 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <limits.h>
  4. #include "lib.h"
  5.  
  6. static int sputc __PROTO((int ch, FILE *fp));
  7.  
  8. static int
  9. sputc (ch, fp)
  10.      int ch;
  11.      FILE *fp;
  12. {
  13.   char **bufp = (char **) fp;
  14.   *(*bufp)++ = ch;
  15.   return ch;
  16. }
  17.  
  18. #ifdef __STDC__
  19. int sprintf(char *buf, const char *fmt, ...)
  20. #else
  21. int sprintf(buf, fmt)
  22.     char *buf;
  23.     const char *fmt;
  24. #endif
  25.     {
  26.     register int n;
  27.     va_list argp;
  28.  
  29.     va_start(argp, fmt);
  30.     n = _doprnt(sputc, (FILE *) &buf, fmt, argp);
  31.     *buf = '\0';        /* always tie of the string */
  32.     return(n);
  33.     }
  34.  
  35. int vsprintf(buf, fmt, args)
  36.     char *buf;
  37.     const char *fmt;
  38.     va_list args;
  39.     {
  40.     register int n;
  41.     n = _doprnt(sputc, (FILE *) &buf, fmt, args);
  42.     *buf = '\0';        /* always tie of the string */
  43.     return(n);
  44.     }
  45.